package com.aplink.generic.pojo.controlspec;

import com.aplink.generic.constant.TabhostDisplay;
import com.aplink.generic.util.AndroidUIParser;

import java.util.ArrayList;

public class TabHostSpec extends ControlSpec {
    private int mStartTab = 0;
    private ArrayList<TabItem> mTabItems;
    private String mBackgroundColor;
    private String mDisplay;

    public TabHostSpec( int startTab, String backgroundColor,
                        String display ) {
        mStartTab = startTab;
        mBackgroundColor = backgroundColor;
        mDisplay = display;
    }

    public int getStartTab() {
        return mStartTab;
    }

    public void setStartTab( int startTab ) {
        mStartTab = startTab;
    }

    public ArrayList<TabItem> getTabItems() {
        return mTabItems;
    }

    public void setTabItems( ArrayList<TabItem> tabItems ) {
        mTabItems = tabItems;
    }

    public TabHostSpec() {
        mTabItems = new ArrayList<TabHostSpec.TabItem>();
        mDisplay = TabhostDisplay.Title.getValue();
    }

    public void add( TabItem tabItem ) {
        mTabItems.add( tabItem );
    }

    public String getBackgroundColor() {
        return mBackgroundColor;
    }

    public int getBackgroundColorId() {
        return AndroidUIParser.getColorIdByName( mBackgroundColor );
    }

    public void setBackgroundColor( String backgroundColor ) {
        mBackgroundColor = backgroundColor;
    }

    public TabhostDisplay getDisplay() {
        return TabhostDisplay.get( mDisplay );
    }

    public void setDisplay( String display ) {
        mDisplay = display;
    }

    public class TabItem {
        private String mPagerItemClass;
        private String mTitle;
        private String mIcon;
        private String mTag;
        private PopupMenuSpec mPopupMenuFormat;

        public String getClassName() {
            return this.mPagerItemClass;
        }

        public void setPagerItemClass( String pagerItemClass ) {
            this.mPagerItemClass = pagerItemClass;
        }

        public String getTitle() {
            return this.mTitle;
        }

        public void setTitle( String title ) {
            this.mTitle = title;
        }

        public String getIcon() {
            return this.mIcon;
        }

        public int getIconId() {
            return AndroidUIParser.getDrawableIdByName( mIcon );
        }

        public void setIcon( String icon ) {
            this.mIcon = icon;
        }

        public TabItem() {

        }

        public TabItem( String pagerItemClass, String title, String icon ) {
            this.mPagerItemClass = pagerItemClass;
            this.mTitle = title;
            this.mIcon = icon;
        }

        public String getTag() {
            return mTag;
        }

        public void setTag( String tag ) {
            mTag = tag;
        }

        public PopupMenuSpec getPopupMenuFormat() {
            return mPopupMenuFormat;
        }

        public void setPopupMenuFormat( PopupMenuSpec popupMenuFormat ) {
            mPopupMenuFormat = popupMenuFormat;
        }
    }
}
